package gitee.derumin.lifeissohard.item;

import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class ImagedCake extends Item {
    public ImagedCake(Settings settings) {
        super(settings);
    }

    @Override
    public boolean hasGlint(ItemStack stack) {
        return true;
    }

    @Override
    public void appendTooltip(ItemStack itemStack, @Nullable World world, List<Text> tooltip, TooltipContext tooltipContext) {
        tooltip.add(Text.translatable("item.lifeissohard.imaged_cake.tooltip1").formatted(Formatting.DARK_PURPLE));
        tooltip.add(Text.translatable("item.lifeissohard.imaged_cake.tooltip2").formatted(Formatting.DARK_PURPLE));
        tooltip.add(Text.translatable("item.lifeissohard.imaged_cake.tooltip3").formatted(Formatting.LIGHT_PURPLE));
    }

    @Override
    public int getMaxUseTime(ItemStack stack) {
        return 64;
    }

    @Override
    public ItemStack finishUsing(ItemStack stack, World world, LivingEntity user) {
        user.addStatusEffect(new StatusEffectInstance(StatusEffects.SATURATION,200));
        return user.eatFood(world, stack);
    }
}
